Summary for Python Codes

Compilation of notes for coding with python

lruolin
03-10-2022

Learning points

CODES

Terminal

Base Python

Other packages

Workflow for normal EDA

LIBRARIES

RETICULATE

Installing libraries

library(reticulate)

## check configuration
# py_config()
# y_discover_config()

# install packages - https://rstudio.github.io/reticulate/articles/python_packages.html
# py_install('pandas')
# py_install('scipy')
# py_install('matplotlib.pyplot')
# py_install('seaborn')
# py_install('scikit-learn')

Creating variables in python

Import libraries Indicate chunk code with Python instead of R.

import numpy as np
my_python_array = np.array([2,4,6,8])
my_python_array
array([2, 4, 6, 8])

Loading python variables into R

my_r_array <- py$my_python_array

Loading R variables back into python

my_python_array_2 = r.my_r_array

References

Citation

For attribution, please cite this work as

lruolin (2022, March 10). pRactice corner: Summary for Python Codes. Retrieved from https://lruolin.github.io/myBlog/posts/20220214 - Compiled Python Notes/

BibTeX citation

@misc{lruolin2022summary,
  author = {lruolin, },
  title = {pRactice corner: Summary for Python Codes},
  url = {https://lruolin.github.io/myBlog/posts/20220214 - Compiled Python Notes/},
  year = {2022}
}